class SectionsController < ApplicationController
  before_filter :login_required
  before_filter :admin_required
  
  def index
    @sections = Section.find(:all)    
  end
  
  def show
    @section = Section.find(params[:id])
  end
  
  def new
    @section = Section.new    
  end
  
  def edit
    @section = Section.find(params[:id])
  end
  
  def create
    @section = Section.create(params[:section])
    
    if @section.save
      flash[:notice] = "New Section Created"
      redirect_to sections_path
    end
  end
  
  def update
    @section = Section.find(params[:id])
    
    if @section.update_attributes(params[:section])
      flash[:notice] = "Successfully Edited Section"
      redirect_to section_path(@section)
    end
  end
  
  def destroy
    Section.find(params[:id]).destroy
    redirect_to sections_path
  end
end